package com.thwcompany.fallback;
import com.thwcompany.dao.IPersonalDao;
import com.thwcompany.pojo.Personal;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;

//客户端的回退处理类IPersonalFallbackFactory，用来处理出现请求服务端时异常，客户端做服务降级。
@Component
@SuppressWarnings("all")
public class IPersonalFallbackFactory implements FallbackFactory<IPersonalDao> {
    @Override
    public IPersonalDao create(Throwable throwable) {
        IPersonalDao iPersonalDao = (int id) -> {
            Personal personal = new Personal();
            personal.setId(9999);
            personal.setName("——服务降级，不存在该用户，或者信息无法查询~");
            personal.setCamp("null");
            personal.setRemarks("无效请求...");
            return personal;
        };
        return iPersonalDao;
    }


}
